﻿using UnityEngine;
using System.Collections;

public class CameraController : MonoBehaviour {
	
	
	public float zCameraSpeed = 75;
	public float xCameraSpeed = 2;
	
	// Use this for initialization
	void Start () {
	
	}
	
	// Update is called once per frame
	void Update () {
		
		//USE ARROW KEYS TO MOVE LEFT, RIGHT, UP AND DOWN ON CERTAIN AXIS
		if (Input.GetKey("w"))
		{
			transform.Translate(0,0,zCameraSpeed * Time.deltaTime,Space.Self);
		}
		
		if (Input.GetKey("s"))
		{
			transform.Translate(0,0,-zCameraSpeed * Time.deltaTime,Space.Self);
		}
		
		if (Input.GetKey("a"))
		{
			transform.Translate(-xCameraSpeed,0,0 * Time.deltaTime,Space.Self);
		}
		
		if (Input.GetKey("d"))
		{
			transform.Translate(xCameraSpeed,0,0 * Time.deltaTime,Space.Self);
		}
		
		//CLAMP TO TERRAIN
		transform.position = new Vector3(transform.localPosition.x,50+Terrain.activeTerrain.SampleHeight(transform.position),transform.localPosition.z);

	}
}
